<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@include file="/WEB-INF/webpage/common/taglibs.jspf"%>
<!DOCTYPE html>
<html>
<head>
    <title>设置处理人</title>
    <meta name="decorator" content="form"/>
    <html:css name="bootstrap-fileinput" />
    <html:css name="simditor,jqgrid" />
</head>

<body class="white-bg"  formid="submitSetForm" beforeSubmit="beforeSubmit">
    <form:form id="submitSetForm" modelAttribute="data"  method="post" action="${adminPath}/activiti/flow/submitFlowSet" class="form-horizontal">
		<form:hidden path="menuId" nested="false"/>
		<form:hidden path="key" nested="false"/>
		<form:hidden path="formUrl" nested="false"/>
		<form:hidden path="billId" nested="false"/>
		<form:hidden path="tableName" nested="false"/>
	</form:form>
	<div class="row">
        <div class="tabs-container">
            <!-- <ul class="nav nav-tabs">
            	<li class="active"><a data-toggle="tab" href="#tab_nodesList" aria-expanded="true">设置节点</a></li>
            </ul> -->
            <div class="tab-content">
                 <div id="tab_nodesList" class="tab-pane active">
                    <div class="panel-body">
                        <grid:grid id="nodesList"  datas="${nodesList}"  gridShowType="form" 
                        	pageable="false"  editable="true" multiselect="false">
							    <grid:column label="节点key"  name="id"  editable="false" hidden="true"       />
							    <grid:column label="节点名称"  name="name"  editable="false" />
							    <grid:column label="处理人Id"  name="assignee"  hidden="true" editable="true" editoptions="{readonly:true}" />
							    <grid:column label="处理人"  name="assigneeName"  editable="true" edittype="custom"  editoptions="editoptions"   datatype="*"     />
						</grid:grid>
						
					</div>
                </div>
            </div>
        </div>
    </div>
<html:js name="bootstrap-fileinput" />
<html:js name="simditor,jqgrid,jqGrid_curdtools,jqGrid_curdtools_inline" />
<script type="text/javascript" src="${staticPath }/common/js/costom_element.js"></script>
<script>
	$(document).ready(function () {
	    $('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
	    	 resizeGrid();
		});
	});
	$(function(){
	   $('#addRowData').hide();
	   $('#delRowData').hide();
	   $(window).resize(function(){   
		   resizeGrid();
	   });
	});
	function resizeGrid(){
		 $("#nodesListGrid").setGridWidth($(window).width()-60);
	}

	/**
	*提交回调方法
	*/
	function beforeSubmit(curform){
		 //这里最好还是使用JSON提交，控制器改变提交方法，并使用JSON方式来解析数
		 //通过判断，如果有问题不提交
		 if(!initGridFormData(curform,"nodesList"))return false;
		 return true;
	}
	
	function initGridFormData(curform,gridId){
		 var rowDatas =getRowDatas(gridId+"Grid");
		 var rowJson = JSON.stringify(rowDatas);
		 if(rowJson.indexOf("editable") > 0&&rowJson.indexOf("inline-edit-cell") )
	     {
	    	 return false;
	     }
		 var gridListJson=$('#'+gridId+"ListJson").val();
		 if(gridListJson==undefined||gridListJson==''){
			 var rowInput = $('<input id="'+gridId+'ListJson" type="hidden" name="'+gridId+'ListJson" />');  
			 rowInput.attr('value', rowJson);  
			 // 附加到Form  
			 curform.append(rowInput); 
		 }else{
			 $('#'+gridId+"ListJson").val(rowJson);
		 }
		 return true;
	}
	
	/**
	 * @description 设置自定义类型.<br>
	 * @date 2017/1/14.<br>
	 * @author zcg .<br>
	 */
	var editoptions = {
		custom_element: gridSelectElem,
		custom_value:gridSelectElemValue,
		gridId:'userGridIdGrid',
		gridUrl:'${adminPath}/sys/user/selectList?orgType=2',
		rowFeild:'realname',
		lableName:'lableName',
		title:'选择处理人',
		callBack:call	
	}		

	/**
	 * @description 回调函数.<br>
	 * @date 2017/1/14.<br>
	 * @author zcg .<br>
	 */
	function call(results,options){
		 debugger
		var rowId = options.rowId;
		$('#'+rowId+"_assignee").val(results[0].id);
	}
</script>
</body>
</html>